using BrettM.BootStrappers;
using BrettM.SimpleDemo.WebApp.Controllers;
using BrettM.SimpleDemo.WebApp.Store;
using BrettM.Web.Hosting;
using BrettM.Web.Restful;
using Microsoft.Practices.Unity;

namespace BrettM.SimpleDemo.WebApp
{
    public class SimpleRestDemoApplication
        : RestHttpApplication
    {

        public override IUnityContainer OnCreateContainer()
        {
            var parent = new UnityContainer();


            var container = parent.CreateChildContainer();

            container
                // BootStrappers
                .RegisterType<IBootStrapper, RestfulRoutesBootStrapper>("RestfulRoutesBootStrapper")
                .RegisterType<IBootStrapper, RestfulControllerFactoryBootStrapper>("RestfulControllerFactoryBootStrapper")
                .RegisterType<IBootStrapper, RestfulErrorHandlerBootStrapper>("RestfulErrorHandlerBootStrapper")

                    
                // Store
                .RegisterInstance<ISimpleDemoStoreFactory>(new SimpleDemoStoreFactory())

                // RESTful controllers
                .RegisterType<IRestController, CustomerController>(typeof(CustomerController).FullName)
                ;

            return container;
        }
    }
}